using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace SmartContentUI.Containers
{
    public partial class ContainerNavigator : UserControl
    {
        #region Variables
        // delegate declaration
        public delegate void OpenItem(object sender);

        // event declaration
        public event OpenItem Open;
        #endregion

        #region Constructor
        public ContainerNavigator(ImageList imgList)
        {
            InitializeComponent();
            this.container_lv.LargeImageList = imgList;
        }
        #endregion

        #region Functions
        public void createDir(TreeNode selectedNode)
        {
            this.container_lv.Items.Clear();
            for (int i = 0; i < selectedNode.Nodes.Count; i++)
            {
                ListViewItem lvItem = new ListViewItem(selectedNode.Nodes[i].Text, selectedNode.Nodes[i].ImageIndex);
                lvItem.Tag = selectedNode.Nodes[i].Tag;
                lvItem.Name = selectedNode.Nodes[i].Name;
                this.container_lv.Items.Add(lvItem);
            }
        }
        public void clearView()
        {
            container_lv.Items.Clear();
        }
        #endregion

        #region Form events
        private void container_lv_DoubleClick(object sender, EventArgs e)
        {
            Open(((ListView)sender).SelectedItems[0]);
        }
        #endregion
    }
}
